<%

Dim ID	
Dim UserName		
Dim News_Title		
Dim News_Content	
Dim News_Use_Day	
Dim Corp_Name
Dim Action
Dim Info_ID

Sub Get_Corp_Sale_Info_Data()

	UserName	 = reform("corp_id")
	News_Title	 = reform("News_Title")	
	News_Content = reform("News_Content")	
	News_Use_Day = reform("News_Use_Day")
	Update_Date	 = now()
	
End Sub 
Sub Corp_Sale_Info_Action()
	Info_ID = Get_ID("Info_ID")
	If Info_ID=0 Then 
		Call Corp_Sale_Info_Add()
	Else
		Call Corp_Sale_Info_Edit()
	End If 
End Sub 
Sub Corp_Sale_Info_Add()	
	

	Call Get_Corp_Sale_Info_Data()

	sql = "INSERT INTO Corp_Sale_News( " &_
		"UserName"&_

		",News_Title"&_
		",News_Content"&_
		",News_Use_Day"&_
		",Update_Date"&_

		") VALUES( " &_
		"'"&UserName&"'"&_

		",'"&News_Title&"'"&_
		",'"&News_Content&"'"&_
		",'"&News_Use_Day&"'"&_
		",'"&Update_Date&"'"&_
		
		")"


    conn.execute(sql)


	AlertBox "信息增加成功！","Corp_Sale_Info_Query.asp"


End Sub

Sub Corp_Sale_Info_Edit()	


	Call Get_Corp_Sale_Info_Data()
	Info_ID = Reform("Info_ID")
	Call Check_IsNumeric(Info_ID)

	sql = "UPDATE Corp_Sale_News Set " &_
		  " UserName ='"&UserName&"'"&_
		  ",News_Title ='"&News_Title&"'"&_		  
		  ",News_Content ='"&News_Content&"'"&_
		  ",News_Use_Day ='"&News_Use_Day&"'"&_
		  ",Update_Date ='"&Update_Date&"'"&_

		  " WHERE ID = "&Info_ID

    conn.execute(sql)

	AlertBox "信息修改成功！","Corp_Sale_Info_Query.asp"

End Sub

Sub Corp_Sale_Info_Del()

	Info_ID = Reform("OP_ID")

	sql = "DELETE FROM  Corp_Sale_News WHERE ID IN ( "&Info_ID &")"

    conn.execute(sql)

	AlertBox "信息删除成功！","Corp_Sale_Info_Query.asp"
	
End Sub

Sub Get_Corp_Sale_Info(ID)

	Info_ID = Get_ID(ID)
	If Info_ID=0 Then 
		Action = "增加"
		Exit Sub 
	End If 

	Sql = "SELECT * FROM Corp_Sale_News WHERE ID="&Info_ID

	Set rs = conn.execute(sql)
	
	If Not rs.eof Then
		UserName	= rs("UserName") 
		News_Title	= rs("News_Title")
		News_Content= rs("News_Content")
		News_Use_Day= rs("News_Use_Day")
		Update_Date	= rs("Update_Date")

	End If
	sql = "SELECT ID,Corp_Name FROM Corp_Info WHERE Corp_Username = '" &UserName&"'"
	Set rs = conn.execute(sql)
	If Not rs.eof Then
		Corp_Name = rs("Corp_Name")		
	End If

	Action="修改"
End Sub 
Function Get_ID(Info_ID)
	If Request.ServerVariables ("Request_Method")="POST" Then
		ID = reform(Info_ID)
	Else
		ID = requery(Info_ID)
	End If 
	If IsNumeric(ID)=False Then 
		Get_ID = 0
	Else
		Get_ID = ID
	End If 
End Function 
Sub Show_Corp_SI(Corp_SI)
	Array_List = GetRsRows("SELECT ID,SI_Name FROM Corp_Service_Item ORDER BY SI_Order ASC ")
	If IsArray(Array_List) Then 
		For i=0 To UBound(Array_List,2)
			Response.Write "<input type=""checkbox"" name=""Corp_SI"" value="""&Array_List(0,i)&""" "&get_check(array_list(0,i),corp_si)&">"&Array_List(1,i)&"&nbsp;&nbsp;&nbsp;&nbsp;"
		Next 
	End If 
End Sub 
Function get_check(d_id,corp_si)
	If IsNull(corp_si) Then 
		get_check = ""
		Exit Function 
	End If 
	corp_si_array = Split(corp_si,",")
	For xx=0 To UBound(corp_si_array)
		If CStr(d_id)=CStr(Trim(corp_si_array(xx))) Then 
			get_check = "checked"
			Exit Function 
			
		End If 

	Next 
	get_check = ""

End function
%>


